﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void miExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void miLogoff_Click(object sender, EventArgs e)
        {
            Application.Restart();         
        }

        private void miCalcMDI_Click(object sender, EventArgs e)
        {
            //ShowMdiForm(new FormCalc((ToolStripMenuItem)sender));
            FormCalc frmCalc = new FormCalc((ToolStripMenuItem)sender);
            frmCalc.MdiParent = this;
            frmCalc.Show();
        }

        private void miCalcDialog_Click(object sender, EventArgs e)
        {
            FormCalc frmCalc = new FormCalc();
            frmCalc.ShowDialog();            
        }

        private void miCalcSDI_Click(object sender, EventArgs e)
        {
            ShowForm(new FormCalc((ToolStripMenuItem)sender));
            //FormCalc frmCalc = new FormCalc((ToolStripMenuItem)sender);
            //frmCalc.Show();
        }

        private void miStuBase_Click(object sender, EventArgs e)
        {
            ShowForm(new FormReader((ToolStripMenuItem)sender));
            //FormStuInfo frmStuInfo = new FormStuInfo((ToolStripMenuItem)sender);
            //frmStuInfo.Show();
        }

        Form ShowForm(Form frm)
        {
            if (frm == null)
                frm = new Form();
            frm.Show();
            return frm;
        }

        Form ShowMdiForm(Form frm)
        {
            if (frm == null)
                frm = new Form();
            frm.MdiParent = this;
            frm.Show();
            return frm;
        }

        private void miAdapter_Click(object sender, EventArgs e)
        {
            ShowMdiForm(new FormAdapter((ToolStripMenuItem)sender));
        }

        private void miStuInfo_Click(object sender, EventArgs e)
        {
            ShowMdiForm(new FormDataView((ToolStripMenuItem)sender));
        }

        private void miBaseStuInfo_Click(object sender, EventArgs e)
        {
            ShowMdiForm(new FormStuInfo((ToolStripMenuItem)sender));
        }
    }
}
